#include "iroperand.h"

#include <iostream>

#include "ir.h"
#include "types.h"
#include "utils.h"

#define VAR BLUE
#define NUM DEF
#define TYPE COLOR(191)

namespace IR {

    void Variable::Print() const {
        // std::cout << this;
        std::cout << VAR << (isGlobal ? "@" : "%");
        std::cout << VAR << name;
        if (memBase) std::cout << "(" << memBase->name << ")";
        std::cout << TYPE << type;
    }
    Operand* Variable::Copy() const { return new Variable(*this); }

    void Immediate::Print() const {
        if (value.type == Type::Basic::Int) std::cout << NUM << value.v.i;
        if (value.type == Type::Basic::Float) std::cout << NUM << value.v.f;
        std::cout << TYPE << type;
    }
    Operand* Immediate::Copy() const { return new Immediate(*this); }

}  // namespace IR
